﻿'Imports System.ComponentModel Required for the Attributes 
'DefaultPropertyAttribute("Title") Indicates the default property for the PropertyGrid (i.e. where cursor is located when loaded) 
'CategoryAttribute("Application") Category attribute indicating the Category to which the property belongs to. Properties belonging to one category are grouped together. 
'Browsable(True) Indicates whether the property is shown in the grid 
'[ReadOnly](False) Indicates that the property is read-only or not 
'BindableAttribute(False) Indicates whether the property can be bound to a data source or not 
'DefaultValueAttribute("") Default value for the property 
'DesignOnly(False) If true, it indicates that the property is Read-only at run time 
'DescriptionAttribute("Enter Title for the application") 


'Dim fname1 As String
'<CategoryAttribute("层基本信息"), _
'Editor(GetType(System.Windows.Forms.Design.FileNameEditor), _
' GetType(System.Drawing.Design.UITypeEditor))> _
'Public Property FnameProperty1() As String
'    Get
'        Return fname1
'    End Get
'    Set(ByVal value As String)
'        If value = "a" Then
'            Return
'        End If
'        fname1 = value
'    End Set
'End Property




'这里先写出相应的伪代码
'这里所写的是通用属性，作为其它层属性的基类
Imports System.IO
Imports System.ComponentModel
Imports System.Windows.Forms.Design
Imports System.Drawing

Public Enum LAYERTYPE
    SHP_LAYER
    BMP_LAYER
    SHP_CREATE_LAYER
    SHP_CREATE_ASIST_LAYER


End Enum

<DefaultPropertyAttribute("层设置")> _
Public Class GPropLayer

    '为兄弟们提供默认值啊！
    Public Sub New(ByVal ln As String, ByVal fn As String, ByVal lt As LAYERTYPE, ByVal bs As Boolean)

        shp_Type = MapWinGIS.ShpfileType.SHP_POLYLINE

        lname = ln
        fname = fn
        lType = lt

        bSelfDef = bs

        desc = ln
        layerTransparent = 100
        linetype = MapWinGIS.tkLineStipple.lsNone
        lineColor = Drawing.Color.Black
        lineWidth = 1
        pointtype = MapWinGIS.tkPointType.ptCircle
        pointsize = 4
        pointColor = Color.Black

        'Dim rm As New Resources.ResourceManager
        ptUdpImg = Nothing


        lblFont = New Font(New FontFamily("Times New Roman"), 8, FontStyle.Regular, GraphicsUnit.Pixel)


        lblColor = Color.Black


        xScale = 1






    End Sub


    '无需暴露给用户的属性
    Public shp_Type As MapWinGIS.ShpfileType
    Public xScale As Double  '这里存储像素与距离之间的比例关系



    '可怕的巨多的需要暴露的，修改事件，55555！
#Region "事件"
    Public Event DescChanged(ByVal ln As String, ByVal ds As String)
    Public Event TransparentChanged(ByVal ln As String, ByVal n As Double)

    Public Event PointSizeChanged(ByVal ln As String, ByVal n As Double)
    Public Event PtClChanged(ByVal ln As String, ByVal cl As Color)
    Public Event PtTypeChanged(ByVal ln As String, ByVal pt As MapWinGIS.tkPointType)

    Public Event LnWdChanged(ByVal ln As String, ByVal d As Double)
    Public Event LnClChanged(ByVal ln As String, ByVal cl As Color)
    Public Event LnTypeChanged(ByVal ln As String, ByVal lt As MapWinGIS.tkLineStipple)

    Public Event PtUdpImgChanged(ByVal ln As String, ByVal img As String)

    Public Event lblFontChanged(ByVal Ln As String, ByVal ft As Font)
    Public Event lblClChanged(ByVal Ln As String, ByVal cl As Color)

#End Region


    '实体相关
    Dim lname As String

    <CategoryAttribute("基本信息"), _
     DisplayName("层ID")> _
    Public ReadOnly Property LnameProperty() As String
        Get
            Return lname
        End Get
        'Set(ByVal value As String)
        '    lname = value
        'End Set
    End Property
    Dim fname As String
    <CategoryAttribute("基本信息"), _
   DisplayName("对应文件")> _
  Public ReadOnly Property FnameProperty() As String
        Get
            Return fname
        End Get
        'Set(ByVal value As String)
        '    fname = value
        'End Set
    End Property



    Dim lType As LAYERTYPE
    <CategoryAttribute("基本信息"), _
   DisplayName("类型")> _
    Public ReadOnly Property LTypeProperty() As LAYERTYPE
        Get
            Return lType
        End Get
        'Set(ByVal value As LAYERTYPE)

        '    lType = value
        'End Set
    End Property


   

    Dim desc As String
    <CategoryAttribute("基本信息"), _
   DisplayName("层描述")> _
    Public Property DescProperty() As String
        Get
            Return desc
        End Get
        Set(ByVal value As String)
            desc = value
            '诱发事件
            RaiseEvent DescChanged(Me.lname, desc)

        End Set
    End Property

    Dim bSelfDef As Boolean '是否属于自定义层，也即是否可以删除

    <CategoryAttribute("基本信息"), _
 DisplayName("自定义层")> _
  Public ReadOnly Property BSelfDefProperty() As Boolean '是否属于自定义层，也即是否可以删除;
        Get
            Return bSelfDef
        End Get
        'Set (ByVal value As Boolean '是否属于自定义层，也即是否可以删除;)
        '          bSelfDef = value
        '      End Set
    End Property



    Dim layerTransparent As Double
    <CategoryAttribute("外观设置"), _
    DisplayName("不透明度")> _
    Public Property LayerTransparentProperty() As Double
        Get
            Return layerTransparent
        End Get
        Set(ByVal value As Double)
            If value > 100 Then
                layerTransparent = 100
                Return
            End If

            If value < 0 Then
                layerTransparent = 0
                Return
            End If
            layerTransparent = value

            RaiseEvent TransparentChanged(Me.lname, layerTransparent)
        End Set
    End Property

    '外表相关
    Dim linetype As MapWinGIS.tkLineStipple

    <CategoryAttribute("外观设置"), _
   DisplayName("线条类型")> _
   Public Overridable Property LinetypeProperty() As MapWinGIS.tkLineStipple
        Get
            Return linetype
        End Get
        Set(ByVal value As MapWinGIS.tkLineStipple)
            linetype = value
            RaiseEvent LnTypeChanged(Me.LnameProperty, linetype)
        End Set
    End Property


    Dim lineColor As Color
    <CategoryAttribute("外观设置"), _
    DisplayName("线条颜色")> _
    Public Overridable Property LineColorProperty() As Color
        Get
            Return lineColor
        End Get
        Set(ByVal value As Color)
            lineColor = value
            RaiseEvent LnClChanged(Me.LnameProperty, lineColor)
        End Set
    End Property
    Dim lineWidth As Double

    <CategoryAttribute("外观设置"), _
   DisplayName("线条宽度")> _
   Public Overridable Property LineWidthProperty() As Double
        Get
            Return lineWidth
        End Get
        Set(ByVal value As Double)
            lineWidth = value

            RaiseEvent LnWdChanged(Me.LnameProperty, lineWidth)
        End Set
    End Property


    Dim pointtype As MapWinGIS.tkPointType
    <CategoryAttribute("外观设置"), _
   DisplayName("点类型")> _
   Public Overridable Property PointtypeProperty() As MapWinGIS.tkPointType
        Get
            Return pointtype
        End Get
        Set(ByVal value As MapWinGIS.tkPointType)
            pointtype = value

            RaiseEvent PtTypeChanged(Me.LnameProperty, pointtype)
        End Set
    End Property

    Dim pointColor As Color
    <CategoryAttribute("外观设置"), _
   DisplayName("点颜色")> _
   Public Overridable Property PointColorProperty() As Color
        Get
            Return pointColor
        End Get
        Set(ByVal value As Color)
            pointColor = value
            RaiseEvent PtClChanged(Me.LnameProperty, pointColor)
        End Set
    End Property
    Dim pointsize As Double
    <CategoryAttribute("外观设置"), _
   DisplayName("点大小")> _
   Public Overridable Property PointsizeProperty() As Double
        Get
            Return pointsize
        End Get
        Set(ByVal value As Double)
            pointsize = value
            RaiseEvent PointSizeChanged(Me.LnameProperty, pointsize)
        End Set
    End Property
    Dim ptUdpImg As String
    <CategoryAttribute("外观设置"), _
   DisplayName("自定义点图片"), _
   Editor(GetType(System.Windows.Forms.Design.FileNameEditor), _
 GetType(System.Drawing.Design.UITypeEditor))> _
    Public Overridable Property PtUdpImgProperty() As String
        Get
            Return ptUdpImg
        End Get
        Set(ByVal value As String)
            ptUdpImg = value

            RaiseEvent PtUdpImgChanged(Me.LnameProperty, ptUdpImg)
        End Set
    End Property
    ' Dim lblFont As Font
    ' <CategoryAttribute("外观设置"), _
    'DisplayName("文本字体")> _
    'Public Property LblFontProperty() As Font
    '     Get
    '         Return lblFont
    '     End Get
    '     Set(ByVal value As Font)
    '         lblFont = value
    '     End Set
    ' End Property
    Dim lblColor As Color
    <CategoryAttribute("外观设置"), _
   DisplayName("文本颜色")> _
   Public Overridable Property LblColorProperty() As Color
        Get
            Return lblColor
        End Get
        Set(ByVal value As Color)
            lblColor = value
            RaiseEvent lblClChanged(Me.LnameProperty, lblColor)
        End Set
    End Property
    ' Dim lblSize As Integer
    ' <CategoryAttribute("外观设置"), _
    'DisplayName("文本大小")> _
    'Public Property LblSizeProperty() As Integer
    '     Get
    '         Return lblSize
    '     End Get
    '     Set(ByVal value As Integer)
    '         lblSize = value
    '     End Set
    ' End Property

    '  Dim bIsShowLable As Boolean
    '  <CategoryAttribute("外观设置"), _
    'DisplayName("显示文本")> _
    ' Public Property BIsShowLableProperty() As Boolean
    '      Get
    '          Return bIsShowLable
    '      End Get
    '      Set(ByVal value As Boolean)
    '          bIsShowLable = value
    '      End Set
    '  End Property

    Dim lblFont As Font
    <CategoryAttribute("外观设置"), _
   DisplayName("文本字体")> _
   Public Overridable Property LblFontProperty() As Font
        Get
            Return lblFont
        End Get
        Set(ByVal value As Font)
            lblFont = value
            RaiseEvent lblFontChanged(Me.LnameProperty, lblFont)
        End Set
    End Property
End Class
